package translinkApp.DialogBoxes.JourneysList;

import translinkApp.Data.Journey.Search.JourneySearch;
import translinkApp.Data.Journey.Search.JourneySearchList;
import translinkApp.Utilities.DataResource;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;

public class JourneysListDialog extends Builder {

	private JourneySearch locationFound;
	
	public JourneySearch getLocationFound() {
		return locationFound;
	}

	public JourneysListDialog(final Context context) {
		super(context);

		final JourneySearchList searches = DataResource.journeysList.getData();
		final CharSequence[] items = new CharSequence[searches.size()];

		for (int i = 0; i < searches.size(); i++) {
			items[i] = searches.get(i).getJourneyName();
		}

		setTitle("Pick a journey");
		setItems(items, new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int item) {

				locationFound = searches.get(item);
			}
		});

	}
}